﻿STR_ERROR_NUMITEMS_OUT_OF_RANGE = "Please enter a value between 3 and 30.";

        function loadSettings()
        {
			//hide the error pane
			errorPane.style.display="none";
        
            this.numItems.value = System.Gadget.Settings.read("numItems");
        }
    	
        function settingsClosing(event)
        {
            if (event.closeAction == event.Action.commit)
            {
				// validate inputs
				
				//validate numItems
				var testNumItems = this.numItems.value;
				if (! (testNumItems >=3 && testNumItems <=30) )
				{
					errorPane.innerText = STR_ERROR_NUMITEMS_OUT_OF_RANGE;
					errorPane.style.display="block";
					
					// cancel the event and ignore the button click
					event.cancel=true;
					return;
				}

				
                System.Gadget.Settings.write("numItems",this.numItems.value);
                
            }
        }